/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { DefaultTask, TaskDetails } from '@ohos/hvigor';

import { CommonConst } from '../../const/common-const.js';
import { ModuleTaskService } from '../service/module-task-service.js';
import { TargetTaskService } from '../service/target-task-service.js';

/**
 * 继承此类的都是以module为基础，提供的hook task，不区分不同的target
 *
 * @since 2022/8/11
 */
export abstract class AbstractModuleHookTask extends DefaultTask {
  protected readonly _moduleService: ModuleTaskService;
  protected readonly _isFaMode;

  protected constructor(moduleService: ModuleTaskService, isFaMode: boolean, taskName: TaskDetails) {
    super(moduleService.getModuleModel().getModule(), taskName);
    this._moduleService = moduleService;
    this._isFaMode = isFaMode;
    this.getWorkerPool().warmUp(CommonConst.WARM_UP_SCRIPT);
  }

  registryAction = (): Function => {
    return () => {
      // This is a hook task, it does nothing
    };
  };

  abstract initTaskDepends(taskTargetService: TargetTaskService): void;
}
